Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(typeinfo): expanding seq doesn't clear locations #1463

Merged
merged 1 commit into from
Sep 25, 2024

Conversation

zerbina
Copy link
Collaborator

@zerbina zerbina commented Sep 25, 2024

Summary

New seq slots are now zeroed when expanding the seq via invokeNewSeq
or extendSeq, making the behaviour consistent with setLen and
newSeq, and also fixing crashes with marshal caused by the
uninitialized memory.

Details

Zeroing the memory is not correct for types that don't have a zero-
default, but those cannot be detected with just RTTI. Zeroing the
memory is usually still better then leaving it as is.

For the JavaScript and VM backends, the zeroMem call is excluded
from compilation. Using invokeNewSeq and extendSeq is already
not possible on these backends.

Fixes #1462

Summary
=======

New seq slots are now zeroed when expanding the seq via `invokeNewSeq`
or `extendSeq`, making the behaviour consistent with `setLen` and
`newSeq`, and also fixing crashes with `marshal` caused by the
uninitialized memory.

Details
=======

Zeroing the memory is not correct for types that don't have a zero-
default, but those cannot be detected with just RTTI. Zeroing the
memory is usually still better then leaving it as is.

For the JavaScript and VM backends, the zeroMem call is excluded from
compilation. Using `invokeNewSeq` and `extendSeq` is already not
possible on these backends.
@zerbina zerbina added bug Something isn't working stdlib Standard library labels Sep 25, 2024
@saem
Copy link
Collaborator

saem commented Sep 25, 2024

/merge

Copy link

Merge requested by: @saem

Contents after the first section break of the PR description has been removed and preserved below:


@chore-runner chore-runner bot added this pull request to the merge queue Sep 25, 2024
Merged via the queue into nim-works:devel with commit c61e95b Sep 25, 2024
35 checks passed
@zerbina zerbina deleted the typeinfo-zero-seq-slots branch September 25, 2024 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stdlib Standard library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash in typeinfo when using the marshal module
2 participants